package com.xiyue.lenovo.actioncateattr;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    //定义一个Action常量
    final static  String LANXI_ACTION =
            "com.xiyue.intent.LANXI_ACTION";
    //定义一个Category常量
    final static  String LANXI_CATEGORY=
            "com.xiyue.category.LANXI_CATEGORY";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bn = (Button) findViewById(R.id.bn);
        bn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                //设置Action属性
                intent.setAction(MainActivity.LANXI_ACTION);
                //添加Category属性
                intent.addCategory(MainActivity.LANXI_CATEGORY);
                startActivity(intent);
            }
        });
    }
}
